import { getToken } from "@/utils/auth";
import { mapState } from "vuex";

export default {
  data() {
    return {
      dataCfgDsv: {
        Authorization: "",
        user: {},
        apiUrl: process.env.VUE_APP_BASE_API,
      },
    };
  },
  computed: {
    ...mapState(["user"]),
  },
  created() {
    // 让每个请求携带自定义token 请根据实际情况自行修改
    this.dataCfgDsv.Authorization = "Bearer " + getToken();
    // 用户信息
    this.dataCfgDsv.user = this.$store.state.user.userInfo;
    this.initDsv()
  },
  mounted() {
    this.initDsv()
  },
  methods: {
    initDsv() {
      // 是否已经固化
      this.dataCfgDsv.isFreezed = this.isFreezed;
      // 申请信息
      if (this.getFormApplyInfo) {
        const applyInfo = this.getFormApplyInfo();
        for (const key in applyInfo) {
          this.dataCfgDsv[key] = applyInfo[key];
        }
      }
      console.log("dataCfgDsv", this.dataCfgDsv);
    },
  },
};
